Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FED-3254 Officially support Dart 3 #958

Merged
merged 25 commits into from
Oct 18, 2024
Merged

FED-3254 Officially support Dart 3 #958

merged 25 commits into from
Oct 18, 2024

Conversation

greglittlefield-wf
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf commented Oct 10, 2024

Related react-dart PR: Workiva/react-dart#409

Motivation

We should support Dart 3.

over_react can currently be consumed in Dart 3, despite not supporting it in its SDK constraints, due to the way Dart 3 treats null-safe packages as compatible.

However, we don't officially support Dart 3, and our automated CI checks don't validate that it works properly in Dart 3.

Also, we still need to support Dart 2 for the time being, so ideally we'd be able to support both Dart 2 and 3 in the same over_react version, and run CI against each Dart version.

Changes

  • Raise SDK constraints to explicitly support Dart 3
  • Fix miscellaneous analysis warnings and test failures in Dart 3
    • See review comments for specifics on these
  • Update CI to run against both Dart 2 and Dart 3
    • In Dart 3 runs, delete non-null-safe browser test cases, since they don't apply in Dart 3 and won't compile
    • Add dart-2-only tag for VM tests that only apply in Dart 2
    • Work around test hanging issue in Dart 3, add test timeouts so CI doesn't hang
    • Break SBOM job out of matrix, since it can only get run once
  • Update dev_dependencies:
    • Widen build_web_compilers to allow newer versions needed by Dart 3
    • Remove unused pedantic and built_value_generator dependencies

Caution

There's a bug in Dart >=3.3.0 <3.5.0 that breaks react-dart behavior in DDC of certain functions passed to components, such as refs and potentially JS callback props: dart-lang/sdk#56897

We can't prevent users on those versions from pulling in react-dart, since they can already resolve to null-safe versions that have already been published.

So, consumers will just have to avoid those versions of Dart, or use dart2js during development or tests.

If needed, we could potentially follow up with a warning that detects this bug and provides a helpful error.

Release Notes

Review

See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.

Please review:

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed
    • Steps from PR author:
      • CI runs in both Dart 2 and 3, and all steps pass
      • Verify the analyzer plugin runs in tools/analyzer_plugin/playground/ in an IDE using Dart 3 (just need to pub get in that directory and you're good)
    • Anything falling under manual testing criteria outlined in CONTRIBUTING.md

Merge Checklist

While we perform many automated checks before auto-merging, some manual checks are needed:

  • A Frontend Frameworks Design member has reviewed these changes
  • There are no unaddressed comments - this check can be automated if reviewers use the "Request Changes" feature
  • For release PRs - Version metadata in Rosie comment is correct

@aviary-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

@greglittlefield-wf greglittlefield-wf changed the title Start running CI on Dart 3 Officially support Dart 3 Oct 16, 2024
@@ -195,34 +195,31 @@ main() {
};

// Loop over the deprecated lifecycle methods
legacyLifecycleMethodsMap.keys.forEach((lifecycle) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were some syntax shenanigans going on here, it looks like from a TS/Dart arrow function syntax mixup 🙂.

This set of curly braces and the ones in the below for-loop are actually being interpreted as set literals, not blocks, were causing warnings.

So, I fixed that and switched from forEach to a for-loop while I was at it.

@@ -132,7 +132,7 @@ class CssValue implements Comparable<CssValue> {

/// Returns whether this value's [number] and [unit] are equal to that of [other].
@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a new built-in Dart warning; apparently == will never be passed a null value (== null bypasses operator==).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting

@@ -63,21 +63,18 @@ mixin DisposableManagerProxy on react.Component implements DisposableManagerV7 {
_getDisposableProxy().listenToStream(stream, onData,
onError: onError, onDone: onDone, cancelOnError: cancelOnError);

@override
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These weren't actually overrides and were infos in Dart 2, but got upgraded to warnings in Dart 3.

@@ -96,13 +96,6 @@ void main() {
testValue: 'test value',
);
});
test('nullable dynamic with extraneous ? syntax', () {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These test cases tested a dynamic? type as an edge case, which now warns instead of infos when used (because the ? is unnecessary).

I tried suppressing those warnings, but dynamic? also appears in the generated part file, and there's no easy way to suppress that warning for just that file.

Since this was an edge-case that warns when the user authors it, preserving the exact type is covered by other test cases, and we originally added this case "just in case", I opted to just remove this case here and in other files.

@@ -15,8 +15,9 @@ analyzer:
missing_return: warning
# Override workiva_analysis_options upgrade to warning
unused_import: info
import_of_legacy_library_into_null_safe: warning
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This no longer exists in Dart 3

@rmconsole3-wf rmconsole3-wf changed the title Officially support Dart 3 FED-3254 Officially support Dart 3 Oct 16, 2024
@greglittlefield-wf greglittlefield-wf marked this pull request as ready for review October 16, 2024 23:12
@robbecker-wf
Copy link
Member

QA+1 CI passes on all combinations of Dart 2 and analyzer. There are validations in place to check that pub resolves the correct analyzer version.
Verified the plugin worked in IDE using Dart 3
Ran some of the examples using Dart 3

@greglittlefield-wf
Copy link
Contributor Author

@Workiva/release-management-p

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from RM

@rm-astro-wf rm-astro-wf merged commit 85ed6a8 into master Oct 18, 2024
11 checks passed
@rm-astro-wf rm-astro-wf deleted the dart-3-ci branch October 18, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants